package com.abcdefg.rabbitmqextensionsdemo.config;


import com.abcdefg.rabbitmqextensionsdemo.constants.Constant;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DelayConfig {


    @Bean("delayExchange")
    public DirectExchange delayExchange() {
        return ExchangeBuilder.directExchange(Constant.DELAY_EXCHANGE).delayed().build();
    }


        @Bean("bindingDelayQueue")
    public Binding bindingDelayQueue(@Qualifier("delayQueue") Queue delayQueue,
                                     @Qualifier("delayExchange") Exchange delayExchange) {
        return BindingBuilder.bind(delayQueue).to(delayExchange).with("delay").noargs();
    }
    @Bean("delayQueue")
    public Queue delayQueue() {
        return QueueBuilder.durable(Constant.DELAY_QUEUE).build();
    }

//    @Bean("delayedExchange")
//    public Exchange delayedExchange() {
//        return ExchangeBuilder.directExchange(Constant.DELAY_EXCHANGE).durable(true).build();
//    }
//
//    @Bean("delayedBinding")
//    public Binding delayedBinding(@Qualifier("delayedExchange") Exchange
//                                          exchange, @Qualifier("delayQueue") Queue queue) {
//        return BindingBuilder.bind(queue).to(exchange).with("delayed").noargs();
//    }
}
